<!DOCTYPE html>
<html lang="en">
<!--header-->
<include file="Public:header"/>
<!--header-->
<section id="main-content">
    <section class="wrapper">
        <h3><i class="fa fa-angle-right"></i> 添加/修改资讯信息</h3>

        <!-- BASIC FORM ELELEMNTS -->
        <div class="row mt">
            <div class="col-lg-12">
                <div class="form-panel">
                    <h4 class="mb">
                        <i class="fa fa-angle-right"></i> 资讯信息
                        <a class="btn btn-theme btn-default" href="{:U('news')}">返回</a>
                    </h4>

                    <form id="myForm" class="form-horizontal style-form" method="post" action="{:U('news_add')}"  enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">置顶为公告</label>
                            <div class="col-sm-10">
                                <input id="type" name="type" value="2"  <if condition="$list.type eq 2">checked</if>  type="checkbox"  class="form-control"   style="width: 8%">
                                <span>如果添加信息为公告请勾选此项！</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">咨询类型</label>
                            <div class="col-sm-10" id="lei">
                                <input id="one" type="radio" name="lei" value="1" <if condition="$list.lei eq 1">checked</if> style="width:30px;height:30px">普通资讯
                                <input id="two" type="radio" name="lei" value="2" <if condition="$list.lei eq 2">checked</if> style="width:30px;height:30px;margin-left: 20px;">付费资讯（报名等）
                            </div>
                        </div>
                        <div class="form-group" id="a" style="display: none;">
                            <label class="col-sm-2 col-sm-2 control-label">价格</label>
                            <div class="col-sm-10">
                                <input name="moneys" value="{$list.moneys}" type="text"  class="form-control" placeholder="请输入价格">
                            </div>
                        </div>
                        <div class="form-group" id="c" style="display: none;">
                            <label class="col-sm-2 col-sm-2 control-label">vip价格</label>
                            <div class="col-sm-10">
                                <input name="vip_moneys" value="{$list.vip_moneys}" type="text"  class="form-control" placeholder="请输入vip价格">
                            </div>
                            <span>如果免费请勿输入价格</span>
                        </div>
                        <div class="form-group" id="b" style="display: none;">
                            <label class="col-sm-2 col-sm-2 control-label">咨询电话</label>
                            <div class="col-sm-10">
                                <input name="phone" value="{$list.phone}" type="text"  class="form-control" placeholder="请输入咨询电话">
                            </div>
                        </div>
                        <div class="form-group" id="banner">
                            <label class="col-sm-2 col-sm-2 control-label">展示图<span style="color: red;">(250px*160px)</span></label>
                            <div class="col-sm-10">
                                <input type="file" name="one" id="avatar" onchange='PreviewImage(this)' style="opacity: 0;display: block;cursor:pointer" />
                                <if condition="$list.img != NULL">
                                    <img class="ph-user"  src="{$list.img}" width="190" height="180" onclick="openFile()" style="cursor:pointer">
                                    <else/>
                                    <img class="ph-user" src="__PUBLIC__/img/wutu.png" alt="" width="190" height="180" onclick="openFile()" style="cursor:pointer">
                                </if>
                            </div>
                        </div>
                        <!--<div class="form-group" >
                            <label class="col-sm-2 col-sm-2 control-label">浏览量</label>
                            <div class="col-sm-10">
                                <input name="nums" value="{$list.nums}" type="number"  class="form-control" placeholder="请输入浏览量">
                            </div>
                        </div>-->
                        <div class="form-group" id="title">
                            <label class="col-sm-2 col-sm-2 control-label">标题</label>
                            <div class="col-sm-10">
                                <input name="title" value="{$list.title}" type="text"  class="form-control" placeholder="请输入消息标题">
                            </div>
                        </div>
                        <div id="content" class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">内容</label>
                            <div class="col-sm-10">
                                <textarea name="content" class="input">{$list.content}</textarea>
                            </div>
                        </div>
                        <input type="hidden"  name="id" value="{$list.id}">
                        <input type="hidden"  name="img" value="{$list.img}">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label"></label>
                            <div class="col-sm-10">
                                <input  type="submit" id="tianjia" class="btn btn-theme" value="保存" style="width: 150px;margin-left: 60px">
                                <input  type="reset" class="btn btn-warning" value="重置" style="width: 150px">
                            </div>
                        </div>
                    </form>
                </div>
            </div><!-- col-lg-12-->
        </div><!-- /row -->
    </section>
</section>
<!--footer-->
<include file="Public:footer"/>
<!--footer-->
<script type="text/javascript" src="__PUBLIC__/ui/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="__PUBLIC__/kindeditor/lang/zh_CN.js"></script>
<script>
    if($("#one").is(":checked")){
        $("#a").hide();$("#b").hide();$("#c").hide();
    }else if($("#two").is(":checked")){
        $("#b").show();$("#a").show();$("#c").show();
    }else{
        $("#a").hide();$("#b").hide();$("#c").hide();
    }
    $("#lei").change(function () {
        if($("#one").is(":checked")){
            $("#a").hide();
            $("#b").hide();
            $("#c").hide();
        }
        if($("#two").is(":checked")){
            $("#b").show();
            $("#a").show();
            $("#c").show();
        }
    })



    if($("#type").is(":checked")){
        $("#banner").hide();
    }else{
        $("#banner").show();
    }
   $("#type").change(function () {
       if($("#type").is(":checked")){
           $("#banner").hide();
       }else{
           $("#banner").show();
       }
    })
    //编辑器
    var editor;
    KindEditor.ready(function(e){
        editor = e.create("[name=content]",{
            "width":"700px",
            "height":"300px",
            allowFileManager:true, //允许对上传图片进行管理
            "items":["source", "|", "undo", "redo", "|", "preview","|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "insertorderedlist", "insertunorderedlist", "indent", "outdent", "subscript", "superscript", "clearhtml","|","formatblock", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline","|", "image"]
        });
    });
    //图片上传
    function openFile(){
        return  $("#avatar").click();
    }

    function PreviewImage(imgFile)
    {
        var filextension=imgFile.value.substring(imgFile.value.lastIndexOf("."),imgFile.value.length);
        var o=imgFile.files[0];
        filextension=filextension.toLowerCase();
        if ((filextension!='.jpg')&&(filextension!='.jpeg')&&(filextension!='.png')&&(filextension!='.bmp')) {
            imgFile.focus();
        }else if(o.size > 2097152){
            imgFile.focus();
        } else {
            var path;
            path=window.URL.createObjectURL(imgFile.files[0]);// FF 7.0以上
            $('.ph-user').attr({src:path});
        }
    }


</script>

</body>
</html>


